<div class="layui-fluid">
  <div class="layui-row">
    <form action="" method="post" class="layui-form layui-form-pane">
      <div class="layui-form-item">
        <input type="hidden" name="id" value="{$id}">
      </div>
      <div class="layui-form-item">
        <label for="house_property_id" class="layui-form-label">
          <span class="x-red">*</span>房产
        </label>
        <div class="layui-input-inline">
          <select name="house_property_id">
            {foreach $property as $v}
            <option value="{$v.id}" {if $v.id===$data.house_property_id}selected{/if}>{$v.name}</option>
            {/foreach}
          </select>
        </div>
      </div>
      <div class="layui-form-item">
        <label for="name" class="layui-form-label">
          <span class="x-red">*</span>房号
        </label>
        <div class="layui-input-inline">
          <input type="text" id="name" name="name" value="{$data.name}" required="" lay-verify="required|max32"
            autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="rental" class="layui-form-label">
          <span class="x-red">*</span>租金
        </label>
        <div class="layui-input-inline">
          <input type="text" id="rental" name="rental" value="{$data.rental}" required="" lay-verify="required|number"
            autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="deposit" class="layui-form-label">
          <span class="x-red">*</span>押金
        </label>
        <div class="layui-input-inline">
          <input type="text" id="deposit" name="deposit" value="{$data.deposit}" required=""
            lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="garbage_fee" class="layui-form-label">
          <span class="x-red">*</span>垃圾费
        </label>
        <div class="layui-input-inline">
          <input type="text" id="garbage_fee" name="garbage_fee" value="{$data.garbage_fee}" required=""
            lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="daily_rent" class="layui-form-label">
          <span class="x-red">*</span>逾期日租金
        </label>
        <div class="layui-input-inline">
          <input type="text" id="daily_rent" name="daily_rent" value="{$data.daily_rent}" required=""
            lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="water_price" class="layui-form-label">
          <span class="x-red">*</span>水费单价
        </label>
        <div class="layui-input-inline">
          <input type="text" id="water_price" name="water_price" value="{$data.water_price}" required=""
            lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <label for="electricity_price" class="layui-form-label">
          <span class="x-red">*</span>电费单价
        </label>
        <div class="layui-input-inline">
          <input type="text" id="electricity_price" name="electricity_price" value="{$data.electricity_price}"
            required="" lay-verify="required|number" autocomplete="off" class="layui-input">
        </div>
      </div>
      <div class="layui-form-item">
        <button class="layui-btn" lay-submit="" lay-filter="save">保存</button>
      </div>
    </form>
  </div>
</div>
<script>
  layui.use(['form', 'layer'], function () {
    $ = layui.jquery;
    var form = layui.form
      , layer = layui.layer;

    //监听提交
    form.on('submit(save)', function (data) {
      //发异步，把数据提交给php
      main.ajaxPost(
        {
          url: "{:url('save')}",
          data: data.field,
        },
        function (data) {
          setTimeout(function () {
            // 获得frame索引
            var index = parent.layer.getFrameIndex(window.name);
            //表格重载
            parent.layui.table.reload('dataGrid');
            //关闭当前frame 
            parent.layer.close(index);
          }, 1000);
        }
      )
      return false;
    });
  });
</script>